package com.any.hook.core.webapi.entity;


import com.any.hook.core.webapi.util.ConstStr;

public class DBInfo {
    private String name;
    private String ip;
    private String port;
    private String driverUrl;
    private String user;
    private String password;
    private String dbname;
    private String driverName;
    private String params;
    private String desc;
    private String fullJDBCURL;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public String getPort() {
        return port;
    }

    public void setPort(String port) {
        this.port = port;
    }

    public String getDriverUrl() {
        return driverUrl;
    }

    public void setDriverUrl(String driverUrl) {
        this.driverUrl = driverUrl;
    }

    public String getUser() {
        return user;
    }

    public void setUser(String user) {
        this.user = user;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getDbname() {
        return dbname;
    }

    public void setDbname(String dbname) {
        this.dbname = dbname;
    }

    public String getDriverName() {
        return driverName;
    }

    public void setDriverName(String driverName) {
        this.driverName = driverName;
    }

    public String getParams() {
        return params;
    }

    public void setParams(String params) {
        this.params = params;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public String getFullJDBCURL() {
        return fullJDBCURL;
    }

    public void setFullJDBCURL(String fullJDBCURL) {
        this.fullJDBCURL = fullJDBCURL;
    }

    public static String getFullDriverUrl(DBInfo dbInfo){
        StringBuilder sb=new StringBuilder();
        sb.append("jdbc:").append(dbInfo.driverName.equals(ConstStr.ORACLE_STR)?"oracle:thin:@":(dbInfo.driverName.equals("dameng")?"dm":dbInfo.driverName)+"://")
                .append(dbInfo.ip).append(":").append(dbInfo.port).append(dbInfo.driverName.equals(ConstStr.ORACLE_STR)?":":"/").append(dbInfo.driverName.equals("dameng")?"":dbInfo.dbname);
        return sb.toString();
    }
    @Override
    public String toString() {
        return "DBInfo{" +
                "name='" + name + '\'' +
                ", ip='" + ip + '\'' +
                ", port='" + port + '\'' +
                ", driverUrl='" + driverUrl + '\'' +
                ", user='" + user + '\'' +
                ", password='" + password + '\'' +
                ", dbname='" + dbname + '\'' +
                ", driverName='" + driverName + '\'' +
                ", params='" + params + '\'' +
                ", desc='" + desc + '\'' +
                '}';
    }
}
